package com.tanzeer.deliverytracker.models;

import java.util.ArrayList;

import android.content.Context;

import com.tanzeer.deliverytracker.dbhelper.RelsellDBOpenHelper;

public class RowItem {

	
	public ItemSummary itemSummary;
	public ActivitySummary activitySummary;
	public int activitySummaryListCount;
	
	
	public class ItemSummary {
		
		public String trackno;
		public String _id;
		public String category;
		public String status;
		public String origin;
		public String destination;
		public String trackName;

		public int completed;
		
		public ItemSummary(String track, String category, String status,
				String origin, String destination, String id,
				String completed, String trackName) {
           this.trackno = track;
           this.category = category;
           this.status = status;
           this.origin = origin;
           this.destination = destination;
           this.trackName = trackName;
           this._id = id;
           if(completed != null) {
              this.completed = Integer.parseInt(completed);
           }
		}
		
		public String toString() {
			String res = "Track No: "+this.trackno +
					     "\nTrack Name: "+this.trackName +
					     "\n\nItem Summary"+
					     "\nOrigin: "+this.origin +
					     "\nDestination: "+this.destination +
					     "\nStatus: "+this.status +
					     "\nCategory: "+this.category;
			             
			return res;
		}
		
	}
	
	public class ActivitySummary {
		public ActivitySummary(String trackno, String activity,
				String location, String remarks, String dateTime) {
			super();
			this.trackno = trackno;
			this.activity = activity;
			this.location = location;
			this.remarks = remarks;
			this.dateTime = dateTime;
		}

		public String trackno;
		public String activity;
		public String location;
		public String remarks;
		public String dateTime;
		
		public String toString() {
			String res = "Activity: "+this.activity +
					     "\nLocal Date/Time: "+this.dateTime +
					     "\nLocation: "+this.location +
					     "\nCategory: "+this.remarks;
			             
			return res;
		}
	}

	
	
	public ArrayList<RowItem> getActivitySummaryItem(Context context,ItemSummary item) {
		ArrayList<RowItem> list = new ArrayList<RowItem>();
        RelsellDBOpenHelper rHelper = new RelsellDBOpenHelper(context);
        rHelper.getActivitySummaryDataForTrack(item._id,item.trackno,list);
		return list;
	}

	public RowItem(String track, String category, String status,
			String origin, String destination, String id, String completed, String trackName) {
		itemSummary = new ItemSummary(track,category,status,origin,destination,id,completed,trackName);
	}
	
	public RowItem(String trackno, String activity,String location, String remarks, String dateTime) {
		activitySummary = new ActivitySummary(trackno,activity,location,remarks,dateTime);
	}

	
	public String toString() {
		String res = null;
		res = this.activitySummary.toString();
		return res;
	}
	
}
